home *** CD-ROM | disk | FTP | other *** search
/ 5 Star Games: DOS Edition 2 / 5 Star Games - DOS Edition (1995)(Ready to Run).iso / dbc / db_crit.c < prev    next >
C/C++ Source or Header  |  1992-03-10  |  2KB  |  89 lines

  1. /****************************************************************************/
  2. /*                         DATABOSS MODULE: DB_CRIT.C                       */
  3. /****************************************************************************/
  4.  
  5. #include "db_lsc.h"
  6.  
  7. #include <dos.h>
  8. #include "db_types.h"
  9. #include "db_crit.h"
  10. #include "db_dos.h"
  11.  
  12. /***************************  INTERNAL CONSTANTS  ***************************/
  13.  
  14. #define ABORT     0
  15. #define CONTINUE  1
  16.  
  17. /***************************  INTERNAL VARIABLES  ***************************/
  18.  
  19. static byte criterrcode = 0;
  20. static word criterrtype = 0;
  21. static word criterrdev = 0;
  22.  
  23. static bool initialized = False;
  24.  
  25. /*****************************  IMPLEMENTATION  *****************************/
  26.  
  27. void clrcriticalerror(void)
  28. {
  29.     criterrcode = 0;
  30. }
  31.  
  32. byte criticalerror(void)
  33. {
  34.     return (criterrcode);
  35. }
  36.  
  37. #ifdef __TURBOC__
  38.     int criterrhandler(int errval, int errtype, int devseg, int devofs)
  39.     /*  Turbo C manual is inconsistent with the DOS programmer reference
  40.             as to the meaning of the registers returned...
  41.  
  42.             Turbo says:-  BP:SI points to device header
  43.             DOS says:-    SI:BP points to device header                      */
  44.     {
  45.         wordptr p;
  46.  
  47.         criterrcode = (byte) errval;
  48.         criterrtype = errtype;
  49.         p = MK_FP(devseg,devofs);
  50.         criterrdev = *p;
  51.         hardresume(3);
  52.       return(ABORT);
  53.     }
  54.  
  55.     int ctrlchandler(void)
  56.     {
  57.         return (CONTINUE);
  58.     }
  59. #else
  60.     void far criterrhandler(word errtype, word errval, word *devhdr)
  61.     {
  62.         criterrcode = (byte) (errval);
  63.         criterrtype = errtype;
  64.         criterrdev = *devhdr;
  65.         hardresume(3);
  66.       return;
  67.     }
  68.  
  69.     void interrupt far ctrlchandler(void){}
  70. #endif
  71.  
  72. /**********************  UNIT INITIALIZATION/EXIT CODE  *********************/
  73.  
  74. void db_crit_init(void)
  75. {
  76.     if (!initialized) {
  77.         initialized = True;
  78.         harderr(criterrhandler);
  79. #ifdef __TURBOC__
  80.         ctrlbrk(ctrlchandler);
  81. #else
  82.     _dos_setvect(0x1B,ctrlchandler);
  83.     _dos_setvect(0x23,ctrlchandler);
  84. #endif
  85.     }
  86. }
  87.  
  88. /****************************  END OF DB_CRIT.C  ****************************/
  89.